﻿@using Happy.Web.Mvc.Paging
@using Ciep.WebSite.Models

@helper RenderPageBar(PagedArticles pageInfo)
{
    <ul class="pagination">
        @{
            var pagebar = pageInfo.Articles.ToPageBarView(9);

            var preClass = pagebar.HasPrevPage() ? "" : "disabled";
            <li class="@preClass"><a href="@pageInfo.PageHref?page=@pagebar.PrevPage()">&laquo;</a></li>

            foreach (var page in pagebar)
            {
                var activeClass = page.IsActive ? "active" : "";
            <li class="@activeClass"><a href="@pageInfo.PageHref?page=@page.Number">@page.Number</a></li>
            }

            var nextClass = pagebar.HasNextPage() ? "" : "disabled";
            <li class="@nextClass"><a href="@pageInfo.PageHref?page=@pagebar.NextPage()">&raquo;</a></li>
        }
    </ul>
}